package com.memory.api;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 主类（项目启动入口）
 */
@SpringBootApplication
@EnableScheduling
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@EnableDubbo
@EnableDiscoveryClient
@EnableFeignClients(basePackages = "com.memory.client.feignClient")
@Slf4j
public class CoreApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(CoreApplication.class, args);
        long start = System.currentTimeMillis();

        long time = (System.currentTimeMillis() - start) / 1000;
        String info = "启动完成，耗时%d秒，swagger访问链接：http://%s:%s%s/doc.html";
        String address = ctx.getEnvironment().getProperty("server.address");
        String port = ctx.getEnvironment().getProperty("server.port");
        String path = ctx.getEnvironment().getProperty("server.servlet.context-path");
        log.info(String.format(info, time, address, port, path));
    }
}
